Ricky Ricotta's Mighty Robot (2000) is a children's novel written by Dav Pilkey and illustrated by Martin Ontiveros, the first in the series of books.
Ricky Ricotta was a lonely mouse who lived in Squeakyville. Once he started school,he got bullied. The villain, Dr. Stinky McNasty created the robot to destroy Earth, but the robot refused. Dr. Stinky McNasty zapped the robot. Luckily Ricky was watching. He smashed the gun. When the robot saw what Ricky had done, the robot became Ricky's friend. Together they defeated Dr. McNasty. Their motto is, "That's what friends are for."